package version

import (
	"runtime"

	"gorm.io/gorm"

	"tuowei.com/cmd/migrate/migration"
	"tuowei.com/cmd/migrate/migration/models"
	common "tuowei.com/common/models"
)

func init() {
	_, fileName, _, _ := runtime.Caller(0)
	migration.Migrate.SetVersion(migration.GetFilename(fileName), _1599190683659Tables)
}

func _1599190683659Tables(db *gorm.DB, version string) error {
	return db.Transaction(func(tx *gorm.DB) error {
		err := tx.Debug().Migrator().AutoMigrate(
			new(models.SysCourseChapterCompletedRecord),
			new(models.SysCourseGift),
			new(models.SysStudyDuration),
			new(models.SysLiveCourse),
			new(models.SysLearningList),
			new(models.SysErrorRecord),
			new(models.SysQuestionBankLink),
			new(models.SysExerciseRecord),
			new(models.SysPracticeRecord),
			new(models.SysIndexCategoryConfig),
			new(models.SysAppConfig),
			new(models.SysKnowledgePoint),
			new(models.SysSubject),
			new(models.SysWxStudent),
			new(models.SysQqStudent),
			new(models.SysEnrollmentTeacher),
			new(models.SysColleges),
			new(models.SysStudent),
			new(models.SysExamination),
			new(models.SysExercise),
			new(models.SysOfflineCourse),
			new(models.SysQuestionBankWare),
			new(models.SysQuestionBank),
			new(models.SysMaterial),
			new(models.SysLecturer),
			new(models.SysClass),
			new(models.SysCourse),
			new(models.SysCourseWare),
			new(models.CasbinRule),
			new(models.SysDept),
			new(models.SysConfig),
			new(models.SysTables),
			new(models.SysColumns),
			new(models.SysMenu),
			new(models.SysLoginLog),
			new(models.SysOperaLog),
			new(models.SysRoleDept),
			new(models.SysUser),
			new(models.SysRole),
			new(models.SysPost),
			new(models.DictData),
			new(models.DictType),
			new(models.SysJob),
			new(models.SysConfig),
			new(models.SysApi),
			new(models.TbDemo),
			new(models.SysConsultLBT),
			new(models.SysConsultWZ),
			new(models.SysFinanceTxmx),
			new(models.Province),
			new(models.OnlineOrder),
			new(models.OfflineOrder),
			new(models.MaterialOrder),
			new(models.SysAddress),
			new(models.OfflineOrderCourse),
			new(models.OnlineOrderCourse),
			new(models.MaterialOrderMaterial),
			new(models.OfflineOrderProgress),
			new(models.SysShoppingCart),
			new(models.SysScore),
			new(models.SysStudentState),
			new(models.SysBalanceDetail),
			new(models.SysTeachingPoint),
			new(models.SysTeachingPoint2Enrollment),
			new(models.SysTeachingPoint2teacher),
			new(models.LinkOrder),
			new(models.SysConfigCommission),
			new(models.SysAcademy),
			new(models.Contract),
		)
		if err != nil {
			return err
		}
		if err := models.InitDb(tx); err != nil {

		}
		return tx.Create(&common.Migration{
			Version: version,
		}).Error
	})
}
